<template>
  <div class="app-container">
    <div class="handle-content">
      <el-input v-if="this.$store.getters.role.store_id == 0" v-model="storeId" placeholder="请输入店铺ID" style="width: 200px;margin-right: 10px;" />
      <el-input v-model="userId" placeholder="请输入用户ID" style="width: 250px;margin-right: 10px;">
        <el-button slot="append" @click="search">查询</el-button>
      </el-input>
    </div>
    <el-tree
      node-key="id"
      :default-expanded-keys="keys"
      :data="nodes"
    />
  </div>
</template>
<script>
import { getTree } from '@/api/member'
export default {

  data() {
    return {
      storeId: '',
      userId: '',
      defaultProps: {
        children: 'children',
        babel: 'title'
      },
      nodes: [],
      keys: []
    }
  },

  mounted() {
    this.getTree()
  },

  methods: {
    search() {
      this.getTree()
    },
    getTree() {
      getTree({ storeId: this.storeId, userId: this.userId }).then(res => {
        this.nodes = res.data.nodes
        this.keys = res.data.keys
      })
    }
  }

}
</script>
